// 代理配置
// 当我遇到/maizuo的时候，代理到xxx地址，并且设置虚拟主机为xxx地址，由于多加了一段xxx，需要用空字符串去掉
// "proxy": {
//   "/maizuo": {
//     "target": "http://m.maizuo.com",
//     "changeOrigin": true,
//     "pathRewrite": {
//       "/maizuo": ""
//     }
//   }
// }
// import axios from 'axios';
// axios.get('/maizuo/v4/api/film/4445?__t=1542247473625')
// .then(resp => {
//   console.log(resp);
// });

import React, { Component } from 'react'

import { connect } from 'react-redux';

import {
  Carousel
} from 'antd-mobile';

import { changeUTitle } from '../../actions/ui';

import './home.less';

import { getSwiper } from '../../services';

@connect(null, { changeUTitle })

export default class Home extends Component {
  constructor() {
    super();
    this.state = {
      swiper: []
    }
  }
  componentDidMount() {
    this.props.changeUTitle('首页');
    getSwiper()
      .then(resp => {
        this.setState({
          swiper: resp.data
        })
      });
  }
  render() {
    return (
      <div>
        <Carousel className="wgd-carousel"
          dots
          swiping
          autoplay
          infinite
          speed={200}
          autoplayInterval={3000}
        >
          {this.state.swiper.map(item => (
            <div 
              className="wgd-item"
              key={item.id}
            >
              <img
                src={item.img}
                alt={item.title}
              />
            </div>
          ))}
        </Carousel>
      </div>
    )
  }
}